Create a web page presentation using R Markdown that features a plot created with Plotly. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a plot created with Plotly. We would love to see you show off your creativity.
Consider the pre-loaded data set “EuStockMarkets” consisting of daily closing prices of major European stock indices, 1991-1998. The markets of interest are DAX, SMI, CAC, and FTSE. We wish to determine a linear model for DAX given SMI, CAC, and FTSE as covariates.
data(EuStockMarkets)
EuStockMarkets <- as.data.frame(EuStockMarkets)
head(EuStockMarkets)
## DAX SMI CAC FTSE
## 1 1628.75 1678.1 1772.8 2443.6
## 2 1613.63 1688.5 1750.5 2460.2
## 3 1606.51 1678.6 1718.0 2448.2
## 4 1621.04 1684.1 1708.1 2470.4
## 5 1618.16 1686.6 1723.1 2484.7
## 6 1610.61 1671.6 1714.3 2466.8
By the following nested likelihood ratio test, FTSE is not a significant covariate.
fit1 <- lm(DAX ~ 1, data = EuStockMarkets)
fit2 <- update(fit1, DAX ~ 1+SMI)
fit3 <- update(fit2, DAX ~ 1+SMI+CAC)
fit4 <- update(fit3, DAX ~ 1+SMI+CAC+FTSE)
anova(fit1,fit2,fit3,fit4)
## Analysis of Variance Table
##
## Model 1: DAX ~ 1
## Model 2: DAX ~ SMI
## Model 3: DAX ~ SMI + CAC
## Model 4: DAX ~ SMI + CAC + FTSE
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 1859 2187625263
## 2 1858 38532840 1 2149092423 179597.275 <2e-16 ***
## 3 1857 22217334 1 16315505 1363.469 <2e-16 ***
## 4 1856 22209221 1 8113 0.678 0.4104
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Therefore we predict DAX with SMI and CAC.
fit_no_int <- lm(DAX ~ SMI + CAC, data=EuStockMarkets)
summary(fit_no_int)
##
## Call:
## lm(formula = DAX ~ SMI + CAC, data = EuStockMarkets)
##
## Residuals:
## Min 1Q Median 3Q Max
## -336.83 -79.21 10.15 82.37 326.60
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.102e+02 1.617e+01 -13.01 <2e-16 ***
## SMI 4.808e-01 4.741e-03 101.42 <2e-16 ***
## CAC 5.017e-01 1.359e-02 36.93 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 109.4 on 1857 degrees of freedom
## Multiple R-squared: 0.9898, Adjusted R-squared: 0.9898
## F-statistic: 9.05e+04 on 2 and 1857 DF, p-value: < 2.2e-16
library(plotly)
plot_ly(EuStockMarkets, x = ~SMI, y = ~CAC, z = ~DAX)
plot_ly(EuStockMarkets, x = ~SMI, y = ~CAC, color = ~DAX)